﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Uploader.cshtml";
}
@section Content {
    <script>

        var orderId = $.request("orderId");
        var no = $.request("No");
        var stateType = $.request("StateType");
        var siteAndSpaceId = $.request("siteAndSpaceId");


        $(function () {
            $.ajax({
                url: "/OrderFlowManage/ClientOrder/GetToken",
                data: {},
                dataType: "json",
                async: false,
                success: function (data) {
                    //console.log(data);
                    $("#token").val(data.token);
                }
            });

            $.ajax({
                url: "/OrderFlowManage/ClientOrder/GetItemJson?enCode=KPLX",
                data: {},
                dataType: "json",
                async: false,
                success: function (data) {
                    var html = '';
                    for (var i = 0; i < data.length; i++) {
                        var item = data[i];
                        html += '<label class="radio-inline">';
                        html += '   <input type="radio" name="optionsRadios" id="optionsRadios' + i + '" value="' + item.Value + '" ' + (i == 0 ? 'checked' : '') + '>';
                        html += item.Text;
                        html += '</label>';
                    }

                    $("#radioPanel").append(html);
                }

            });
        });

        function submitForm() {

            if (!$('#testform').formValid()) {
                return false;
            }

            var userfile = $("#userfile").val();
            var filePath = $("#userfilepath").val(),
                fileCode = $("#FileCode").val(),
                //fileName = $("#userfilename").val(),
                fileName = $("#FileName").val(),
                fileDate = $("#FileDate").val(),
                fileType = $("#radioPanel input[type='radio'][checked]").val();
            var params = {
                OrderId: orderId,
                SiteAndSpaceId: siteAndSpaceId,
                No: no,
                FilePath: filePath,
                FileCode: fileCode,
                FileName: fileName,
                FileType: fileType,
                FileDate: fileDate,
                StateType: stateType
            };
            $.submitForm({
                url: "/OrderFlowManage/ClientOrder/SubmitSiteFileForm?keyValue=" + orderId,
                param: params,
                success: function () {
                    $.currentWindow().vm.impress.initImpress();
                    $.loading(false);
                }
            });
        }
    </script>
}

<div style="padding-top: 20px; margin-right: 20px;">
    <div class="container">
        <!-- Document：https://developer.qiniu.com/kodo/manual/form-upload -->
        <form id="testform" method="post" enctype="multipart/form-data">
            <table class="form">
                <tr>
                    <th class="formTitle">合同编号</th>
                    <td class="formValue">
                        <input id="FileCode" name="FileCode" type="text" class="form-control required" />
                    </td>
                    <th class="formTitle">合同名称</th>
                    <td class="formValue">
                        <input id="FileName" name="FileName" type="text" class="form-control required" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">签约时间</th>
                    <td class="formValue">
                        <input id="FileDate" name="FileDate" type="text" class="form-control input-wdatepicker required" readonly onfocus="WdatePicker()" />
                    </td>
                    <th class="formTitle">合同类型</th>
                    <td class="formValue">
                        <div id="radioPanel">
                        </div>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">选择合同</th>
                    <td class="formValue" colspan="3">
                        <input name="key" id="key" type="hidden" value="">
                        <input id="token" name="token" type="hidden" value="">
                        <input id="userfile" name="file" type="file" class="form-control required" placeholder="请录入订单阶段" />
                        <input id="userfilepath" name="userfilepath" type="hidden" />
                        <input id="userfilename" name="userfilepath" type="hidden" />

                        <!-- take photo with phone -->
                        <!-- <input id="userfile" name="file" accept="image/*" type="file" /> -->
                        <!-- take video with phone -->
                        <!-- <input id="userfile" name="file" type="file" accept="video/*"/> -->
                        <input name="accept" type="hidden" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">操作描述</th>
                    <td class="formValue" colspan="3">
                        <!-- upload info -->
                        <div class="selected-file"></div>
                        <div class="progress"></div>
                        <div class="uploaded-result"></div>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>


